package com.weijian.config.common;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * Knife4j配置类
 *
 * @author weijian
 */
@Configuration
public class Knife4jConfig {

    @Value("${server.port:8080}")
    private String port;

    /**
     * 配置OpenAPI文档基本信息
     *
     * @return OpenAPI配置对象
     */
    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("🎬 视频播放DEMO API文档")
                        .description("基于Spring Boot + MyBatis-Plus + MinIO的视频播放平台，支持大文件上传、分片上传、视频播放等核心功能")
                        .version("v1.0.0")
                        .contact(new Contact()
                                .name("weijian")
                                .email("weijian@example.com")
                                .url("https://gitee.com/weijian-huang/video_demo"))
                        .license(new License()
                                .name("Apache 2.0")
                                .url("https://www.apache.org/licenses/LICENSE-2.0")))
                .servers(List.of(
                        new Server().url("http://localhost:" + port).description("本地开发环境")
                ));
    }
}